#!/bin/bash

echo "========================================"
echo "Fall Data 批量清理和获取依赖脚本"
echo "========================================"
echo ""

MODULES=("fall_data_base" "fall_data_gen" "fall_data_main")

for module in "${MODULES[@]}"; do
    echo "========================================"
    echo "处理模块: $module"
    echo "========================================"
    
    if [ -d "$module" ]; then
        cd "$module" || exit 1
        
        echo "[$module] 执行 flutter clean..."
        flutter clean
        if [ $? -ne 0 ]; then
            echo "[错误] $module 执行 flutter clean 失败"
            cd ..
            exit 1
        fi
        echo "[$module] flutter clean 完成"
        echo ""
        
        echo "[$module] 执行 flutter pub get..."
        flutter pub get
        if [ $? -ne 0 ]; then
            echo "[错误] $module 执行 flutter pub get 失败"
            cd ..
            exit 1
        fi
        echo "[$module] flutter pub get 完成"
        echo ""
        
        cd ..
    else
        echo "[警告] 模块目录不存在: $module"
        echo ""
    fi
done

echo "========================================"
echo "所有模块处理完成！"
echo "========================================"
